package main

import (
	"fmt"
	"math/rand"
	"time"
)

//斐波那契
func Fibonacci(a uint8, b uint8, limit uint8) {
	x := a + b
	y := a + 2*b
	if x < limit && y < limit {
		fmt.Println(x, y)
		Fibonacci(x, y, limit)
	} else if x < limit && y > limit {
		fmt.Println(x)
		fmt.Printf("%d以内的最大的斐波那契数为%d", limit, x)
	} else {
		fmt.Printf("结束，斐波那契%d以内最大的数是%d", limit, b)
	}
}

func main() {
	//第一题作业
    for i := 1; i < 10; i++ {
		for j := 1; j <= i; j++ {
			x := j * i
			fmt.Printf("%d*%d=%d\t", j, i, x)
		}
		fmt.Println()
	}

    //第二题作业
    var sum uint64 = 0
	var product uint64 = 1
	randomSource := rand.New(rand.NewSource(time.Now().UnixNano()))
	for i := 0; i < 20; i++ {
		randomNumber := randomSource.Intn(99) + 1
		fmt.Println(randomNumber)
		if i&1 == 0 {
			sum += uint64(randomNumber)
		} else {
			product *= uint64(randomNumber)
		}
	}
	fmt.Println(sum, product)

    //第三题
    Fibonacci(1,2,20)
}